#include <stdio.h>
#include "./../h265_decoder.h"
int main()
{
	char vps_buf[52];
	int vps_len = 0;
	char sps_buf[52];
	int sps_len = 0;
	char pps_buf[52];
	int pps_len = 0;
	// const char frame1[]={0x22,0x65,0x00,0x00,0x00,0x01,0x40,0x01,0x0C,0x01,0xFF,0xFF,\
			     // 0x01,0x60,0x00,0x00,0x03,0x00,0xB0,0x00,0x00,0x03,\
                             // 0x00,0x00,0x03,0x00,0x99,0xAA,0x02,0x40};
	// unsigned int frame1_size = 30;
	// const char frame2[]={0x00,0x00,0x00,0x01,0x42,0x01,0x01,0x01,0x60,0x00,\
			     // 0x00,0x03,0x00,0xB0,0x00,0x00,0x03,0x00,0x00,0x03,\
			     // 0x00,0x99,0xA0,0x01,0x44,0x20,0x07,0x91,0x63,0x6A,\
			     // 0xA4,0x93,0x2F,0x90};
	// unsigned int frame2_size = 34;
	// const char frame3[]={0x00,0x00,0x00,0x01,0x44,0x01,0xC0,0xF2,0xF0,0x3C,\
			     // 0x90};
	// unsigned int frame3_size = 11;
	
	const char frame1[]={0x00,0x00,0x00,0x01,0x40,0x01,0x0C,0x01,0xFF,0xFF,\
						 0x01,0x60,0x00,0x00,0x03,0x00,0xB0,0x00,0x00,0x03,\
                         0x00,0x00,0x03,0x00,0x99,0xAA,0x02,0x40};
	unsigned int frame1_size = 30;
	const char frame2[]={0x00,0x00,0x00,0x01,0x42,0x01,0x01,0x00,0x80,0x00,\
						 0x00,0x03,0x00,0x00,0x03,0x00,0x00,0x03,0x00,0x00,\
						 0x03,0x00,0x00,0xA0,0x06,0x82,0x01,0xE1,0xFE,0x59,\
			             0x49,0x92,0x46,0xD8,0x61,0x62,0x2A,0xA4,0xC4,0xC3,\
						 0x2F,0xB3,0xEB,0xCD,0xF9,0x67,0xD7,0x85,0x11,0x89,\
						 0xCB,0xB2};
	unsigned int frame2_size = 52;
	const char frame3[]={0x00,0x00,0x00,0x01,0x44,0x01,0xC0,0xF2,0xF0,0x3C,\
			             0x90};
	unsigned int frame3_size = 11;
	
	h265_unit_type type = get_nal_type(frame1,frame1_size,vps_buf,&vps_len);
	printf("type of frame1 is %d  nal_len %d\n",type,vps_len);

	type = get_nal_type(frame2,frame2_size,sps_buf,&sps_len);
	printf("type of frame2 is %d  nal_len %d\n",type,sps_len);

	type = get_nal_type(frame3,frame3_size,pps_buf,&pps_len);
	printf("type of frame3 is %d  nal_len %d\n",type,pps_len);
	/*
	for(int i =0;i<sps_len;++i)
	{
		printf("%d\t",(unsigned int)((unsigned char)(sps_buf[i])));
	}
	printf("\n");*/
	int width = 0;
	int height = 0;
	decode_width_height(sps_buf,sps_len,&width,&height);
	printf("width %d   height %d\n",width,height);
	return 0; 
}

